package prepro;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;

import myLucene.Props;

public class LowerCase {
	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new FileReader(new File(
				"/local/joofeit/dewacCleanNew")));
		Directory iDirectory = FSDirectory.open(new File(Props.readIndexPath));
		// IndexSearcher searcher = new IndexSearcher(iDirectory, true);
		//	
		// IndexReader iReader = searcher.getIndexReader();
		BufferedWriter bw = new BufferedWriter(new FileWriter(new File(
				"/local/joofeit/TermsLowerCaps")));
		String line = "";
		// HashMap<String, Integer> dict = Searcher.dictSize(iReader);
		HashSet<String> terms = new HashSet<String>();
		while ((line = br.readLine()) != null) {
			if (line.split(" ").length == 3) {
				terms.add(line.split(" ")[2].trim().toLowerCase());
			} else {
				System.out.println(line);
			}
		}
		for (String s : terms) {
			bw.write(s + "\n");
		}
		bw.flush();
		bw.close();
		br.close();
	}

}
